package test230604;

/**
 * @author 兴趣使然黄小黄
 * @version 1.0
 * @date 2023/6/4 16:40
 * 461. 汉明距离
 * https://leetcode.cn/problems/hamming-distance/
 */
public class Solution01 {

    public int hammingDistance(int x, int y) {
        int count = 0;
        while (x > 0 || y > 0) {
            if ((x & 1) != (y & 1)) {
                ++count;
            }
            x >>= 1;
            y >>= 1;
        }
        return count;
    }
}
